home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Online / LineShare 3.3.1 / LineShare Scripts / Supra Voice&Fax1&ARA&Data < prev    next >
Text File  |  1995-01-11  |  13KB  |  702 lines

  1. !V3.0
  2. !
  3. !$ Use this script with Supra 14400bps and 9600bps fax modems.
  4. !$ Supports: voice, fax, and ARA incoming calls.
  5. !
  6. !$ Make sure that *Class 1* fax software is installed, and that
  7. !$ your modem has voice-capable ROMs.
  8. !
  9. !$ A hardware handshaking cable is required.
  10.  
  11. ^2 Fax Software:     = Enum("FaxSTF 2.x Class 1" = "0","FaxSTF 3.x/Faxilitate"="1","FaxSTF Class 2" = "2","Delrina"="3","4-Sight"="4") "0"
  12. ^3 Error Correction: = Bool("Enabled"="\N3","Disabled"="\N0") "\N0"
  13. ^4 Handshake wires:  = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
  14. ! ------------------------------------------
  15. ! Resetting the modem:
  16. ! ------------------------------------------
  17. @HANGUP
  18.   SerReset 19200,0,8,1
  19.   HsReset 0,0,17,19,0,0
  20.   Flush
  21.   SetTries 2
  22.   write "ATH0S0=0\r"
  23.   Flush
  24.  
  25. !
  26. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  27. ! to enter the command mode
  28. !
  29. @Label 1
  30.   write "AT+VC=0\r"
  31.   flush
  32.   write "AT&F1V1\r"
  33.   matchclr
  34.   matchstr 1 2 "OK\r\n"
  35.   matchread 20
  36.   Chrdelay 1
  37.   Write "+++"
  38.   Chrdelay 0
  39.   DtrClear
  40.   SBreak
  41.   DtrSet
  42.  
  43.   write "AT+VC=0\r"
  44.   matchclr
  45.   matchstr 1 1 "OK\r\n"
  46.   matchread 10
  47. !
  48.   Write "ATE0V1\r"
  49.   Matchstr 1 1 "OK\r\n"
  50.   Matchread 10
  51.  
  52.   write "ATH0\r"
  53.   matchstr 1 1 "OK\r\n"
  54.   matchread 10
  55.   DecTries
  56.   IfTries 0 1
  57.   exit -6019
  58.  
  59. @Label 2
  60.   SerReset 19200,0,8,1
  61.   Jsr 80
  62.   Write "AT+FCLASS=0;+FAE=0\r"
  63.   Jsr 100
  64.   exit 0
  65.  
  66.  
  67. ! ------------------------------------------
  68. !    Receiving incoming calls
  69. ! ------------------------------------------
  70. @ANSWER
  71.   SerReset 19200,0,8,1
  72. @Label 3
  73.   Jsr 70
  74.  
  75.   ifOpen "Voice" 11
  76. !
  77. ! Waiting for Fax/ARA calls only (no Voice App running)
  78.   Note "Voice Application is not running..."
  79.  
  80. !  No Voice App running -- turn off caller ID
  81.   Write "AT#CID=0\r"
  82.   Jsr 100
  83.  
  84. !  This would allow us to not go into AA mode if we could have more labels.
  85.   ifOpen "ARA"  4
  86.   IfOpen "Data" 4
  87.   ifOpen "Fax"  4
  88.   Note "No services active: the modem will not answer."
  89.   Pause 600
  90.   Jump 3
  91.  
  92. ! Fax/Data only (no voice)
  93. @Label 4
  94.   Jsr 130
  95.   Jsr 55
  96. !
  97. ! Fetch the tube after S0 rings
  98.   SetVar B "S0=2"
  99.   GetCommand A "Fax" "S0"
  100.   IfStr A 5 "S0=0"
  101.   IfStr A 5 ""
  102.   SetVar B "^A"
  103. @Label 5
  104.   Write "AT^B\r"
  105.   Jsr 100
  106. !
  107. ! Tell the modem to detect the type of the incoming call
  108. ! Switch to the "numeric" mode, if necessary
  109.   SetVar A "1"
  110.   Jsr 56
  111.  
  112. !
  113. ! Everything is ready - let's sit and wait for a call
  114.   Note "Waiting for a fax or ARA/Data call..."
  115.   Jsr 175
  116.   IfStr A 20 "Data"
  117.   IfStr A 40 "Fax1"
  118.   IfStr A 45 "Fax2"
  119.   Jump 3
  120.  
  121. ! ---------- Voice Mode ---------
  122. ! check to see if the voice code has been downloaded
  123. ! if not, tell PhonePro to download it.
  124. !
  125. @Label 11
  126.   Note "Checking the modem..."
  127.   Write "AT+VC=0\r"
  128.   Jsr 120 
  129.   Write "AT+VC=1\r"
  130.   MatchClr
  131.   MatchStr 1 14 "OK\r\n"
  132.   MatchStr 2 13 "ERROR\r\n"
  133.   MatchRead 20
  134.   Exit -6019
  135. !
  136. !  tell the Voice Tool to download the voice code
  137. !
  138. @Label 13
  139.   Note "Downloading voice code to modem..."
  140.   Pause 20
  141.   QueueInput "\r\nLOAD\r\n"
  142.   Attach "Voice" (Master)
  143.  
  144. @Label 14
  145.   Write "AT+VC=0\r"
  146.   Jsr 100
  147.  
  148. !
  149. ! sit and wait for a call for up to 30 seconds, then re-initiate the modem
  150. ! Get caller ID, if voice enabled
  151. !! QueueInput "\r\nGET_CALLER_ID_FLAG\r\n"
  152. !! Attach "Voice" (Master)
  153. !! SetVar B "^$"
  154. !! Write "AT#CID=^B\r"
  155. !! Jsr 100
  156.  
  157.   Note "Waiting for a Voice/Fax/ARA/Data call"
  158.   MatchClr
  159.   MatchStr 1 15 "RING\r\n"
  160.   MatchRead 1800
  161.   Jump 3
  162.  
  163. @Label 15
  164.   Note "Ring..."
  165.   QueueInput "\r\nRING\r\n"
  166.   Attach "Voice" (Master)
  167.   Write "+++"
  168.   Note "Switching from voice..."
  169.  
  170. ! fall through if the call is not a voice call (as indicated by the telephone tool)
  171. !
  172.   SetVar A "^$"
  173.   SerReset 19200,0,8,1
  174.   HsReset 0,0,17,19,0,0
  175.   Jsr 80
  176.  
  177.   IfStr A 17 "Fax"
  178.   IfStr A 18 "ARA"
  179.   Exit -6019
  180.  
  181. !
  182. ! Force to answer a Fax call
  183. !
  184. @Label 17
  185.   Note "Answering a fax call..."
  186.   SetVar A "0"
  187.   Jsr 56
  188.   Write "ATA\r"
  189.   Jsr 175
  190.   ifStr A 40 "Fax1"
  191.   ifStr A 45 "Fax2"
  192.   Write "\r"
  193.   Exit -6019
  194.  
  195. !
  196. ! Force to answer an ARA/Data call
  197. !
  198. @Label 18
  199.   Note "Answering a data call..."
  200.   Jsr 70
  201. ! Set the communication options:
  202.   Jsr 55
  203.   Write "AT+FAA=0;+FCLASS=0\r"
  204.   Jsr 100
  205.   Write "ATA\r"
  206.   Jsr 180
  207.   IfStr A 20 "Data"
  208.   Write "\r"
  209.   Exit -6019
  210.  
  211. !
  212. ! Data connection has been established (we read "CONNECT")
  213. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  214. ! if it was an incoming call, put the "RING" before the "CONNECT"
  215. !
  216. @Label 20
  217.   IfOpen "Data" 21
  218.   Jump 30
  219. @Label 21
  220.   IfOpen "ARA" 22
  221.   Jump 35
  222. @Label 22
  223.   Note "Waiting for an ARA frame"
  224.   MatchClr
  225.   MatchStr 1 23 "^$\r"
  226.   MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
  227.   MatchStr 3 29 "\01\27\02\29\01\02\01\06"
  228.   MatchRead 40
  229.   Jump 24
  230. @Label 23
  231.   QueueInput "^$\r"
  232. @Label 24
  233.   Note "Non-ARA call"
  234.   Jump 35
  235.  
  236. @Label 28
  237.   Note "ARA 1.0 call"
  238.   Jump 30
  239. @Label 29
  240.   Note "ARA 2.0 call"
  241.   Jump 30
  242.  
  243. @Label 30
  244.   QueueInput "\r\nCARRIER ^B\r\n"  
  245.   IfStr C 31 "NONE"
  246.   QueueInput "\r\nREL\r\n"
  247. @Label 31
  248.   IfOriginate 32
  249.   QueueInput "\r\nRING\r\n"
  250. @Label 32
  251.   Attach "ARA" (DTR)
  252.  
  253. @Label 35
  254.   GetSReg C "DATA" 4
  255.   QueueInput "\r^CCONNECT ^B\r^C"
  256.   ifOriginate 36
  257.   QueueInput "\r^CRING\r^C"
  258. @Label 36
  259.   Attach "Data" (DTR,Escape,Break,IdleLimit=60)
  260.  
  261. !
  262. ! Fax Class 1 connection has been established
  263. ! Attach the "Fax" subPort
  264. @Label 40
  265.   QueueInput "1\r"
  266.   ifOriginate 41
  267.   QueueInput "2\r"
  268. @Label 41
  269.   IfStr 2 42 "0"
  270.   Attach "Fax" (DTR,Reset)
  271. @Label 42
  272.   Attach "Fax" (DTR,Reset(2400))
  273.  
  274. !
  275. ! Fax Class 2 connection has been established
  276. ! Attach the "Fax" subPort
  277. @Label 45
  278.   QueueInput "\r\n+FCON\r\n"
  279.   ifOriginate 46
  280.   QueueInput "\r\nRING\r\n"
  281. @Label 46
  282.   IfStr 2 47 "2"
  283.   Attach "Fax" (DTR)
  284. @Label 47
  285.   Attach "Fax" (DTR,Reset)
  286.  
  287. ! ------------------------------------------
  288. ! Originating a call through the "Voice" subport
  289. ! ------------------------------------------
  290. @ORIGINATE "Voice" ("\r\nBUSY\r\n")
  291.   Note "PhonePro is originating a call ..."
  292.   SerReset *
  293.   HsReset *
  294.   Attach "Voice" (Escape, Master)
  295.   Exit -6019
  296.  
  297.  
  298.  
  299. ! ------------------------------------------
  300. ! Originating a call through the "ARA" subport
  301. ! ------------------------------------------
  302. @ORIGINATE "ARA"
  303.   Jsr 51
  304.   Jump 30
  305.  
  306. ! ------------------------------------------
  307. ! Originating a call through the "Data" subport
  308. ! ------------------------------------------
  309. @ORIGINATE "Data"
  310.   Jsr 51
  311.   Jump 35
  312.  
  313. @Label 51
  314.   SerReset 38400,0,8,1
  315.   Jsr 80
  316. !
  317. ! Set the common options & Comm options
  318.   Jsr 70
  319.   Jsr 55
  320. !
  321. ! Prepare to receive all error result codes, dial the number
  322.   Write "ATDT^1\r"
  323.   Jsr 180
  324.   IfStr A 103 "Data"
  325.   Write "\r"
  326.   Exit -6019
  327.  
  328. ! ------------------------------------------
  329. ! Originating a call through the "Fax" subPort
  330. ! ------------------------------------------
  331. @ORIGINATE "Fax" ("\r\nBUSY\r\n")
  332. ! Clear the modem's magic memory
  333.   Jsr 130
  334.   SerReset *
  335.   HsReset *
  336.   Jsr 80
  337.   Write "ATZ\r"
  338.   Jsr 100
  339.   Write "AT+VC=0\r"
  340.   Jsr 120
  341. !
  342. ! Set the common options
  343.   Jsr 70
  344.  
  345. !
  346. ! Set the Fax mode
  347.   SetVar A "2"
  348.   Jsr 56 
  349.   Write "AT+VC=0\r"
  350.   Jsr 120
  351.  
  352. !
  353. ! Now emit all commands that the application has sent to that port,
  354. ! except "+FCLASS", etc
  355. !
  356.   EmitClear "+FCLASS","V","E","S0"
  357.   Jsr 60
  358.  
  359. !
  360. ! Switch the verbos mode, if necesary
  361. !
  362.   Jsr 58
  363.  
  364.   Write "ATD^1\r"
  365.   Jsr 175
  366.   HsReset *
  367.   IfStr A 40 "Fax1"
  368.   IfStr A 45 "Fax2"
  369.   Write "\r"
  370.   Exit -6019
  371.  
  372. !
  373. ! Set the communication options:
  374. ! • \N0 &Q6: Normal connection (for ARA)
  375. ! • &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  376. ! • W1:  report connection speed
  377. !
  378. @Label 55
  379.   Write "AT^3&K3W1\r"
  380.   Jsr 100
  381.   return
  382.  
  383. !
  384. ! Tuning the fax mode
  385. @Label 56
  386.   ifStr 2 57 "0"
  387.   ifStr 2 57 "1"
  388.   Write "AT+FCLASS=2\r"
  389.   Jsr 100
  390.   GetCommand A "Fax" "+FLID="
  391.   Jsr 99
  392.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  393.   Jsr 100
  394.   GetCommand A "Fax" "+FDCC="
  395.   Jsr 99
  396.   GetCommand A "Fax" "+FBOR="
  397.   Jsr 99
  398.   ifStr A 103 "0"
  399.   ifStr A 103 "2"
  400.   Write "AT+FAA=1;+FCLASS=0\r"
  401.   Jump 100
  402.  
  403. @Label 57
  404.   Write "AT&K4+FCLASS=1\r"
  405.   Jsr 100
  406.   ifStr A 103 "2"
  407.   ifStr A 58 "0"
  408.   Write "AT+FAE=1;+FCLASS=0\r"
  409.   Jsr 100
  410. @Label 58
  411.   ifStr 2 59 "0"
  412.   ifStr 2 59 "1"
  413.   return
  414. @Label 59
  415.   Write "ATV0\r"
  416.   Jump 110
  417.  
  418. !
  419. ! This section emits all modem commands sent from the client application
  420. ! For each set of commands the "OK" answer is awaited
  421. !
  422. @Label 60
  423.   EmitStart
  424. @Label 61
  425.   EmitCommand 62
  426.   Jsr 100
  427.   Jump 61
  428. @Label 62
  429.   return
  430. !
  431. ! This section initiates the modem before ANSWER and ORIGINATEs:
  432. ! extended responses + connect at the highest rate + speaker control +
  433. ! reset on Dtr drop + DCD valid
  434. ! Verbal responses mode, no echo
  435. !
  436. @Label 70
  437.   Write "ATX4N1^4&C1V1E0\r"
  438.   Jsr 100
  439.   return
  440.  
  441. !
  442. ! This section syncronize the modem after the serial port speed switching
  443. !
  444. @Label 80
  445.   ChrDelay 1
  446.   Write "\r\r"
  447.   Pause 2
  448.   Write "AT\r"
  449.   ChrDelay 0
  450.   Jsr 100
  451.   return
  452. !
  453. ! Prepare to receive error result codes, send the dialing command and
  454. ! set the user's handshake mode
  455. !
  456. @Label 90
  457.   MatchClr
  458.   MatchStr 2 91 "NO DIALTONE\r\n"
  459.   MatchStr 3 92 "BUSY\r\n"
  460.   MatchStr 4 93 "NO CARRIER\r\n"
  461.   MatchStr 5 94 "NO ANSWER\r\n"
  462.   Write "ATD^1\r"
  463.   HsReset *
  464.   return
  465.  
  466. @Label 91
  467.   exit -6020
  468. @Label 92
  469.   exit -6022
  470. @Label 93
  471.   exit -6021
  472. @Label 94
  473.   exit -6023
  474. !
  475. ! Processing the AT command:
  476. ! OK -> proceed
  477. ! ERROR or TimeOut ->exit -6019
  478. ! It can be called AFTER the "Write" command, since LineShare buffers input
  479. !
  480. @Label 99
  481.   Write "AT^A\r"
  482. @Label 100
  483.   MatchClr
  484.   MatchStr 1 103 "\r\nOK\r\n"
  485.   MatchStr 2 102 "\r\nERROR\r\n"
  486. @Label 101
  487.   MatchRead 20
  488. @Label 102
  489.   Exit -6019
  490. @Label 103
  491.   return
  492.  
  493. @Label 110
  494.   MatchClr
  495.   MatchStr 1 103 "0\r"
  496.   MatchStr 2 102 "4\r"
  497.   Jump 101
  498.  
  499. @Label 120
  500.   MatchClr
  501.   MatchStr 1 103 "\r\nOK\r\n"
  502.   MatchStr 2 103 "\r\nERROR\r\n"
  503.   MatchRead 20
  504.   Exit -6019
  505.  
  506. !This zeros out a location in memory that
  507. !when cleared, enables STF to send/receive faxes.
  508. @Label 130
  509.   MatchClr
  510.   Write "AT!2000M\r"
  511.   MatchStr 1 131 "\r\n2000: "
  512.   MatchRead 20
  513.   Jump 150
  514.  
  515. @Label 131
  516.   MatchClr
  517.   Write "00"
  518.   MatchStr 1 132 "\r\n2001: "
  519.   MatchRead20
  520.   Jump 150
  521.  
  522. @Label 132
  523.   MatchClr
  524.   Write "00"
  525.   MatchStr 1 133 "\r\n2002: "
  526.   MatchRead 20
  527.   Jump 150
  528.  
  529. @Label 133
  530.   MatchClr
  531.   Write "00"
  532.   MatchStr 1 134 "\r\n2003: "
  533.   MatchRead 20
  534.   Jump 150
  535.  
  536. @Label 134
  537.   MatchClr
  538.   Write "00"
  539.   MatchStr 1 135 "\r\n2004: "
  540.   MatchRead 20
  541.   Jump 150
  542.  
  543. @Label 135
  544.   MatchClr
  545.   Write " "
  546.   Jsr 100
  547.  
  548. @Label 136
  549.   MatchClr
  550.   Write "AT!2007M\r"
  551.   MatchStr 1 137 "\r\n2007: "
  552.   MatchRead 20
  553.   Jump 150
  554.  
  555. @Label 137
  556.   MatchClr
  557.   Write "00"
  558.   MatchStr 1 138 "\r\n2008: "
  559.   MatchRead20
  560.   Jump 150
  561.  
  562. @Label 138
  563.   MatchClr
  564.   Write "00"
  565.   MatchStr 1 139 "\r\n2009: "
  566.   MatchRead20
  567.   Jump 150
  568.  
  569. @Label 139
  570.   MatchClr
  571.   Write "00"
  572.   MatchStr 1 140 "\r\n200A: "
  573.   MatchRead20
  574.   Jump 150
  575.  
  576. @Label 140
  577.   MatchClr
  578.   Write "00"
  579.   MatchStr 1 141 "\r\n200B: "
  580.   MatchRead20
  581.   Jump 150
  582.  
  583. @Label 141
  584.   Write " "
  585.   Jsr 100
  586.   return
  587.  
  588. @Label 150
  589.   Note "Error clearing the modem's memory"
  590.   Pause 50
  591.   Write "   "
  592.   return
  593.  
  594. !
  595. ! Connection. On exit, variables contain:
  596. ! ^A - NONE, Data or Fax
  597. ! ^B - connection speed
  598. ! ^C - PROTOCOL used
  599. @Label 175
  600.   ifStr 2 190 "0"
  601.   ifStr 2 190 "1"
  602. @Label 180
  603.   SetVar C "NONE"
  604.   MatchClr
  605.   MatchStr 01 182 "RING\r\n"
  606.   MatchStr 02 183 "PROTOCOL: ^$\r\n"
  607.   MatchStr 03 184 "CARRIER ^$\r\n"
  608.   MatchStr 04 185 "CONNECT ^$\r\n"
  609.   MatchStr 05 186 "+FCON\r\n"
  610.   MatchStr 06  91 "NO DIALTONE\r\n"
  611.   MatchStr 07  92 "BUSY\r\n"
  612.   MatchStr 08  93 "NO CARRIER\r\n"
  613.   MatchStr 09  94 "NO ANSWER\r\n"
  614. @Label 181
  615.   MatchRead 1200
  616.   SetVar A "NONE"
  617.   return
  618.  
  619. @Label 182
  620.   Note "Ring…"
  621.   Jump 181
  622. @Label 183
  623.   SetVar C "^$"
  624.   Jump 181
  625. @Label 184
  626.   SetVar B "^$"
  627.   Jump 181
  628. @Label 185
  629.   SetVar A "Data"
  630.   return
  631. @Label 186
  632.   SetVar A "Fax2"
  633.   return
  634.  
  635.  
  636. @Label 190
  637.   SetVar C "NONE"
  638.   MatchClr
  639.   MatchStr 01 191 "70\r"
  640.   MatchStr 02 193 "77\r"
  641.   MatchStr 03 193 "80\r"
  642.  
  643.   MatchStr 04 194 "47\r"
  644.   MatchStr 05 195 "48\r"
  645.   MatchStr 06 196 "49\r"
  646.   MatchStr 07 197 "50\r"
  647.   MatchStr 08 198 "51\r"
  648.   MatchStr 09 199 "52\r"
  649.  
  650.   MatchStr 10 200 "16\r"
  651.   MatchStr 11 200 "17\r"
  652.   MatchStr 12 200 "18\r"
  653.  
  654.   MatchStr 13 192 "2\r"
  655.   MatchStr 14 201 "1\r"
  656.   MatchStr 15 191 "33\r"
  657.  
  658.   MatchStr 16 91 "6\r"
  659.   MatchStr 17 92 "7\r"
  660.   MatchStr 18 93 "3\r"
  661.   MatchStr 19 94 "8\r"
  662.  
  663. @Label 191
  664.   MatchRead 1200
  665.   SetVar A "NONE"
  666.   return
  667.  
  668. @Label 192
  669.   Note "Ring…"
  670.   Jump 191
  671.  
  672. @Label 193
  673.   SetVar C "REL"
  674.   Jump 181
  675.  
  676. @Label 194
  677.   SetVar B "2400"
  678.   Jump 191
  679. @Label 195
  680.   SetVar B "4800"
  681.   Jump 191
  682. @Label 196
  683.   SetVar B "7200"
  684.   Jump 191
  685. @Label 197
  686.   SetVar B "9600"
  687.   Jump 191
  688. @Label 198
  689.   SetVar B "12000"
  690.   Jump 191
  691. @Label 199
  692.   SetVar B "14400"
  693.   Jump 191
  694.  
  695. @Label 200
  696.   SetVar A "Data"
  697.   return
  698.  
  699. @Label 201
  700.   SetVar A "Fax1"
  701.   return
  702.